package com.nba.dao.impl;

import java.util.Date;
import java.util.List;

import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;

import com.nba.bean.New;
import com.nba.dao.NewDao;
import com.nba.util.DBUtil;

public class NewDaoImpl implements NewDao {
		
	JdbcTemplate jt = new JdbcTemplate(DBUtil.getDataSource());
	
	@Override
	public List<New> selectNewAll() {
		String sql = "SELECT * FROM new";
		List<New> list = jt.query(sql, new BeanPropertyRowMapper<New>(New.class));
		return list;
	}

	@Override
	public int insertNew(String newTheme, String newContent, String newUrl, Date newTime, int typeId) {
		String sql = "INSERT INTO new(new_theme , new_content , new_url , new_time,type_id) Value(?,?,?,?,?)";
		return jt.update(sql,newTheme, newContent, newUrl, newTime, typeId);
	}

}
